/**
 * Created by shenhai on 15/9/7.
 */

var regionService = require('../../../services/mis/system/regionService');
var messageUtil = require('../../../common/utils/messageUtil');
var toolUtil = require('../../../common/utils/toolUtil');


exports.regionPrivince = function(req, res) {

    regionService.provinceService(req, function(err, results) {

        if (err) {
            logger.error('Exception happen when regionPrivince...' + err.message);
            res.json(messageUtil.composeFailedMessage(req, 'Exception happen when regionPrivince...'));
        }else {
            res.json(messageUtil.composeSucceededMessage(req, null, results));
        }

    });
};

exports.regionCity = function(req, res) {

    regionService.cityService(req, function(err, results) {

        if (err) {
            logger.error('Exception happen when regionCity...' + err.message);
            res.json(messageUtil.composeFailedMessage(req, 'Exception happen when regionCity...'));
        }else {
            res.json(messageUtil.composeSucceededMessage(req, null, results));
        }

    });
};

exports.regionCounty = function(req, res) {

    regionService.countyService(req, function(err, results) {

        if (err) {
            logger.error('Exception happen when regionCounty...' + err.message);
            res.json(messageUtil.composeFailedMessage(req, 'Exception happen when regionCounty...'));
        }else {
            res.json(messageUtil.composeSucceededMessage(req, null, results));
        }

    });
};
/*  宝宝树66小区二次改造    add   gct  20170802   start   */
exports.communityList=function(req,res)
{
    regionService.villageService(req, function(err, results) {

        if (err) {
            logger.error('Exception happen when regionCounty...' + err.message);
            res.json(messageUtil.composeFailedMessage(req, 'Exception happen when regionCounty...'));
        }else {
            res.json(messageUtil.composeSucceededMessage(req, null, results));
        }

    });
};
/*  宝宝树66小区二次改造    add   gct  20170802   end   */